<template>
    <slot :controller="controller" :store="store" :model="model">
    <div :class="classNames">
        <slot name="page_containerContainer" :controller="controller" :store="store" :model="model" >
        <AppStandardContainer 
            name="page_container"
            v-show="store.layoutModelDetails?.page_container?.visible"
            :isMultiContainer="false"
            :layoutModelDetails="store.layoutModelDetails">
            <template #container_grid1>
                <slot name="container_grid1Container" :controller="controller" :store="store" :model="model" >
                <AppSimpleFlexContainer 
                    name="container_grid1"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #container1>
                        <slot name="container1Container" :controller="controller" :store="store" :model="model" >
                        <AppStandardContainer 
                            name="container1"
                            v-show="store.layoutModelDetails?.container1?.visible"
                            :isMultiContainer="false"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #view_pagecaption>
                                <slot name="view_pagecaption" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetCaption 
                                    v-if="model.showCaption && !noViewCaption"
                                    name="view_pagecaption"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    {{model.caption}}
                                </AppPresetCaption>
                                </slot>
                            </template>
                        </AppStandardContainer>
                        </slot>
                    </template>
                    <template #container_2>
                        <slot name="container_2Container" :controller="controller" :store="store" :model="model" >
                        <AppStandardContainer 
                            name="container_2"
                            v-show="store.layoutModelDetails?.container_2?.visible"
                            :isMultiContainer="false"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #toolbar>
                                <slot name="toolbar" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                <AppCtrlPos name="toolbar" :layoutModelDetails="store.layoutModelDetails">
                                </AppCtrlPos>
                                </slot>
                            </template>
                        </AppStandardContainer>
                        </slot>
                    </template>
                </AppSimpleFlexContainer>
                </slot>
            </template>
            <template #container3>
                <slot name="container3Container" :controller="controller" :store="store" :model="model" >
                <AppStandardContainer 
                    name="container3"
                    v-show="store.layoutModelDetails?.container3?.visible"
                    :isMultiContainer="false"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #form>
                        <slot name="form" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                        <AppCtrlPos name="form" :layoutModelDetails="store.layoutModelDetails">
                            <slot name="IBIZOrderUIPART_0009Form" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                <IBIZOrderUIPART_0009Form
                                    
                                    :actions="{
                                        loadAction: 'Get',
                                        loadDraftAction: 'GetDraft',
                                        updateAction: 'Update',
                                        createAction: 'Create',
                                        removeAction: 'Remove',
                                        wfSubmitAction: 'WFSubmit',
                                        wfStartAction: 'WFStart',
                                    }"
                                    :openView="store.openView"
                                    :newView="store.newView"
                                    name="form"
                                    v-bind="model.ctrlParams.IBIZOrderform"
                                    :context="store.context"
                                    :viewParams="store.viewParams"
                                    :closeView="store.closeView"
                                    :pLoadingHelper="store.loadingHelper"
                                    :pViewCtx="store.viewCtx"
                                    @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                                    @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                                    @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"    />
                            </slot>
                            </AppCtrlPos>
                        </slot>
                    </template>
                </AppStandardContainer>
                </slot>
            </template>
        </AppStandardContainer>
        </slot>
    </div>
    </slot>
</template>

<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@DEEDITVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppCtrlPos, AppScrollContainer, AppSimpleFlexContainer, AppStandardContainer, AppTabPanel, AppTabPage } from '@components/layout-element/structure';

import IBIZOrderUIPART_0009Form from '@widgets/ibiz-order/uipart-0009-form/uipart-0009-form.vue';
import { useProps, useBasic, useAction, useController } from './ibiz-order-f-8-edit-view-hook';
import { IEvent, EditViewActionType, IEditViewAbility, IEditViewStore, IParam } from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    getClassNames, 
    useNavParamsBind,
	useEventBind,
    handleQuickSearch,
  	handleToolbarItemClick,
    handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy
} = useBasic(props);

const emit = defineEmits<{
    (event: 'view-action', name: string, action: EditViewActionType, data: IParam[]): void;
    (event: 'view-init', name: string, data: IEditViewAbility): void;
    (event: 'view-mounted', name: string, data: IParam): void;
    (event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: IEditViewStore = controller.getStore();

onMounted(() => {
    controller.viewMounted();
})

onUnmounted(() => {
    controller.viewDestroy();
})
</script>
